package com.shierke.Ume.ui.activity.me

import android.app.Activity
import android.content.Context
import android.graphics.Color
import android.os.Bundle
import com.shierke.Ume.base.BaseDialogActivity
import com.shierke.Ume.bean.VipVistorsBean
import com.shierke.Ume.util.startActivity
import com.youth.banner.adapter.BannerImageAdapter
import com.youth.banner.holder.BannerImageHolder
import kotlinx.android.synthetic.main.activity_dialog_deblock_vistors.*
import com.youth.banner.indicator.CircleIndicator
import com.bumptech.glide.load.resource.bitmap.RoundedCorners
import com.bumptech.glide.request.RequestOptions
import com.bumptech.glide.Glide
import com.shierke.Ume.R
import com.shierke.Ume.util.click
import com.youth.banner.indicator.Indicator

/**
 * Create by Ybx
 * on 2020-10-13
 * Desribe:
 */
class DeblockingVistorsDialogActivity : BaseDialogActivity() {


    companion object {

        fun startActivity(context: Context) {
            context.startActivity<DeblockingVistorsDialogActivity>()
            var activity = context as Activity
            activity.overridePendingTransition(R.anim.report_cause_in, 0)
        }
    }


    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        setContentView(R.layout.activity_dialog_deblock_vistors)
        setStatusBarTransparentAndFullScreen(this)


        var arrayList = arrayListOf<VipVistorsBean>().apply {
            add(VipVistorsBean(R.mipmap.vip_lun1))
            add(VipVistorsBean(R.mipmap.vip_lun2))
            add(VipVistorsBean(R.mipmap.vip_lun3))
            add(VipVistorsBean(R.mipmap.vip_lun4))
            add(VipVistorsBean(R.mipmap.vip_lun5))
        }

        var adapter1 = object : BannerImageAdapter<VipVistorsBean>(arrayList) {
            override fun onBindView(
                holder: BannerImageHolder?,
                data: VipVistorsBean?,
                position: Int,
                size: Int
            ) {
                Glide.with(holder!!.itemView)
                    .load(data!!.imagePath)
                    .apply(RequestOptions.bitmapTransform(RoundedCorners(30)))
                    .into(holder.imageView)
            }
        }

        banner1.adapter = adapter1
        banner1.addBannerLifecycleObserver(this)
        banner1.indicator = CircleIndicator(this) as Indicator?

        banner1.setIndicatorSelectedColor(Color.parseColor("#8020FE"))
        banner1.setIndicatorNormalColor(Color.parseColor("#9C9C9C"))


        type1.click {
            type1.isSelected = true
            type2.isSelected = false
            type3.isSelected = false
        }

        type2.click {
            type2.isSelected = true
            type1.isSelected = false
            type3.isSelected = false
        }


        type3.click {
            type3.isSelected = true
            type2.isSelected = false
            type1.isSelected = false
        }

    }


    override fun onStart() {
        super.onStart()
        banner1.start()
    }

    override fun onStop() {
        super.onStop()
        banner1.stop()
    }

    override fun onDestroy() {
        super.onDestroy()
        banner1.destroy()

    }


}